﻿@{
    ViewBag.Title = "教学大纲";
    Layout = "~/Views/Shared/_TreeLayout.cshtml";
}


<!--树-->


<!--Operation-->
<div class="heading-buttons">
    <input type="hidden" value="@ViewBag.Id" id="CourseId"/>

    <div class="col-xs-12 col-sm-7 col-md-7 col-lg-4">
        <h1 class="page-title txt-color-blueDark"><i class="fa  fa-pencil "></i>
            编辑教学大纲			
        </h1>
    </div>
    <div class="buttons pull-right">

        <button type="button" class="btn btn-success btn-labeled " id="btnTeaCatalogAdd"
            data-bind="click: $root.AddNewNode">
            <span class="btn-label"><i class="glyphicon glyphicon-plus"></i>
            </span>添加章节</button>

        <button type="button" class="btn btn-primary btn-labeled " id="btnTeaCatalogDel"
            data-bind="click: $root.DelNode">
            <span class="btn-label"><i class="glyphicon glyphicon-remove"></i>
            </span>删除章节</button>


    </div>
    <div style="clear: both;">
    </div>
</div>
<!--/Operation-->


<hr class="separator" />
<!-- Bread crumb is created dynamically -->


<div class="row">

    <div class="col-sm-6" style="margin-bottom: 5px; margin-top: 5px;">
        <div class="well well-light well-sm no-margin no-padding treeContent">
            <!--TeaCatalog tree-->
            <ul id="TeaCatalogTree" class="ztree">
            </ul>
        </div>

    </div>
    <!-- end col-sm-61 -->
    <!--/TeaCatalog tree-->


    <!--TeaCatalog  information-->
    <div class="col-sm-6" style="margin-bottom: 5px; margin-top: 5px;">
        <div class="well well-light well-sm no-margin no-padding treeContent">
            <input type="hidden" id="hidId" />
            <form class="form-horizontal" id="frmTeaCatalog" data-bind="with: NodeValue">

                <fieldset>
                    <div class="row" style="border-bottom: dashed 1px; margin-bottom: 10px;">
                        <h3 style="padding: 10px 0 10px 10px; float: left;"><strong>详细信息</strong></h3>
                        <div class="buttons pull-right">


                            <button type="button" id="btnTeaCatalogUpdate" class="btn btn-success btn-labeled " style="margin-top: 5px;" data-bind="click: $root.updateNode">
                                <span class="btn-label"><i class="fa fa-save"></i>
                                </span>保存
                            </button>
                        </div>
                    </div>

                    <div style="clear: both;" />
                    <div class='form-group'>
                        <label class='col-md-2 control-label' style='margin-bottom: 3px;'>章节名:</label><div class='col-md-9'>
                            <input type='text' id='txtbSCaptailName' name='txtbSCaptailName' placeholder='第几章 或 第几节' class='form-control' data-bind='value:SCaptailName' />
                        </div>
                    </div>

                    <div class='form-group'>
                        <label class='col-md-2 control-label' style='margin-bottom: 3px;'>章节标题:</label><div class='col-md-9'>
                            <input type='text' id='txtbSTitle' name='txtbSTitle' placeholder='章节标题' class='form-control' data-bind='value:STitle' />
                        </div>
                    </div>

                    <input type='hidden' id='txtbIParentId' name='txtbIParentId' class='form-control' data-bind='value:IParentId' />


                    <input type='hidden' id='txtbILevel' name='txtbILevel' class='form-control' data-bind='value:ILevel' />


                    <div class='form-group'>
                        <label class='col-md-2 control-label' style='margin-bottom: 3px;'>重要度:</label><div class='col-md-9'>
                            <input type='text' id='txtbIImportance' name='txtbIImportance' placeholder='等级：1-9' class='form-control' data-bind='value:IImportance' />
                        </div>
                    </div>


                    <div class='form-group'>
                        <label class='col-md-2 control-label' style='margin-bottom: 3px;'>学时:</label><div class='col-md-9'>
                            <input type='text' id='txtbIHourse' name='txtbIHourse' placeholder='学时' class='form-control' data-bind='value:IHourse' />
                        </div>
                    </div>

                    <div class='form-group'>
                        <label class='col-md-2 control-label' style='margin-bottom: 3px;'>大纲简介，200字以内:</label>
                        <div class='col-md-9'>
                            <textarea id='txtbSIntrodece' name='txtbSIntrodece' placeholder='' class='form-control' data-bind='value:SIntrodece'></textarea>
                        </div>
                    </div>

                </fieldset>

            </form>
        </div>
    </div>
</div>

<!-- end row -->
<!--/TeaCatalog information-->


<script type="text/javascript">

    var viewModel;
    $(function () {


        var options = {

            renderDiv: $("#TeaCatalogTree"),
            hidId: $("#hidId"),
            frmElement: $("#frmTeaCatalog"),



            UpdateBtn: $("#btnTeaCatalogUpdate"),
            AddBtn: $("#btnTeaCatalogAdd"),
            DelBtn: $("#btnTeaCatalogDel"),


            //节点数据
            NodeValue: ko.observable({

                Id: 0,
                STitle: '',
                IParentId: 0,
                ILevel: 0,
                ISort: 0,
                IDeanCourseId: '',
                IHourse: 0,
                SUrl: '',
                SIntrodece: '',
                SCaptailName: '',
                IImportance:1
            }),

            //用户查询URL
            dataQueryUrlAccessor: function () { return "/api/Teacher/TreeAll?iDeanCourseId=" + $("#CourseId").val(); },

            //添加用户URL
            dataAddUrlAccessor: function (key) {
                
                return "/api/Teacher/AddTreeNode?id=" + key + "&CourseId=" + $("#CourseId").val();
            },
            dataUpdateAccessor: function (key) { return "/api/Teacher/PutTreeNode/" + key; },
            dataDeleteAccessor: function (key) { return "/api/TeaCatalog/Delete/" + key; },
            dataNodeSelect: function (id) { return "/api/TeaCatalog/get/" + id; }

			, showDlgBefore: function () {
			    //显示对话框之前

			}
                , showDetailEnd: function (data) {


                }
             , changeEnd: function (key, event) {
                 //对话框保存的后置事件
             }, initEd: function () {
                 //gird初始化的后置事件 信息

             }

        };

        viewModel = new ViewModel(options);


        viewModel.init();
        ko.applyBindings(viewModel);




        options.frmElement.validate({
            rules: {
                txtbSTitle: { maxlength: 50 },
                txtbIHourse: { digits: true },
                txtbSUrl: { maxlength: 50 },
                txtbSIntrodece: { maxlength: 400 },
                txtbSCaptailName: { required: true },
                txtbIImportance: { digits: true, max: 9, min: 1, required: true }
            },
            messages: {
                txtbSTitle: { maxlength: '最大长度为1000' },
                txtbIHourse: { digits: '必须是整数' },
                txtbSIntrodece: { maxlength: '最大长度为200' },
                txtbSCaptailName: { required: '章节名必须填' },
                txtbIImportance: { digits: '必须是整数', max: '最大值为9', min: '最小值为1', required: '请填写重要度' }
            }
        });

    });

</script>




<!--end 树code-->


